package message.validate.demo.service;

import lodsve.core.utils.StringUtils;
import lodsve.validate.exception.ErrorMessage;
import lodsve.validate.exception.ExceptionHandler;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * .
 *
 * @author sunhao(sunhao.java @ gmail.com)
 * @version 1.0 2017/12/12 15:24
 */
@Component
public class TestExceptionHandler extends ExceptionHandler {

    @Override
    public String getMessage(List<ErrorMessage> messages) {
        List<String> msgs = new ArrayList<>(messages.size());
        for (ErrorMessage em : messages) {
            msgs.add(em.getMessage());
        }

        return StringUtils.join(msgs, "####");
    }
}
